package com.yl.nettylearning.netty.day10;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * @author yangl
 */
public class LongToByteEncoder extends MessageToByteEncoder<Long> {

    /**
     * 编码
     * @param ctx
     * @param msg
     * @param out
     * @throws Exception
     */
    @Override
    protected void encode(ChannelHandlerContext ctx, Long msg, ByteBuf out) throws Exception {
        System.out.println("LongToByteEncoder中的encode方法被调用");
        System.out.println("msg = " + msg);
        out.writeLong(msg);
    }
}
